package ldh.serialize.type;

import java.io.IOException;
import java.math.BigDecimal;

import ldh.serialize.BinarySerialized;
import ldh.serialize.io.ByteBuf;
import ldh.serialize.util.SerializedUtil;

public class BigDecimalSerialized implements BinarySerialized<BigDecimal> {

	@Override
	public void write(ByteBuf out, BigDecimal decimal) throws IOException {
		SerializedUtil.writeString(out, decimal.toString());
	}

	@Override
	public BigDecimal read(ByteBuf in) throws IOException {
		String str =  SerializedUtil.readString(in);
		return new BigDecimal(str);
	}

	@Override
	public Class<BigDecimal> getClassType() {
		return BigDecimal.class;
	}
}
